<html>

<head>
<link rel="stylesheet" href="bootstrap.min.css" />
<script src="jquery-1.8.0.min.js"></script> 

<script>

//获得参数的方法

var request = { 

 QueryString : function(val) { 

 var uri = decodeURI(window.location.search); 

 var re = new RegExp("" +val+ "=([^&?]*)", "ig"); 

 return ((uri.match(re))?(uri.match(re)[0].substr(val.length+1)):null); 

 } 

}

</script>

</head>

<body>
<div style="overflow:auto;position: relative;">
   <div id="wwf" class="table table-bordered table-striped">
                     		<table id=table>						
							<thead>
							<tr>							   
							    <th><nobr>订单日期</nobr></th>
							    <th><nobr>配送日期</nobr></th>
							    <th><nobr>调度</nobr></th>
							    <th><nobr>项目</nobr></th>
							    <th><nobr>客户</nobr></th>
							    <th><nobr>配送类型</nobr></th>
							    <th><nobr>货物</nobr></th>
							    <th><nobr>线路备注</nobr></th>
							    <th><nobr>门店</nobr></th>
							    <th><nobr>司机</nobr></th>
							    <th><nobr>车牌</nobr></th>
							    <th><nobr>配送员</nobr></th>
							    <th><nobr>备注</nobr></th>							    					 
							</tr>
							</thead>
							<tbody>							
							<!-- <tr>
							    <th></th>						
								<th></th>
								<th></th>						
								<th></th>
								<th></th>						
								<th></th>
								<th></th>						
								<th></th>
								<th></th>						
								<th></th>
								<th></th>						
								<th></th>
								<th></th>																																														
							</tr>		 --> 				
							</tbody>							
						</table>
  </div>
</div>
<div>
<P id="a01">未派车门店:</P>
<P id="a02">未出车司机:</P>
<P id="a03">未使用车辆:</P>

</div>

<script>
//调用方法获得参数
var rt = request.QueryString("inputStr");
//数据提取
var varAllDb1 = rt.slice(0,rt.search("a001a")).split(',');//车牌 varAllDb1
var varAllDb2 = rt.slice(rt.search("a001a")+5,rt.search("a002a")).split(',');//司机 varAllDb2
var varAllDb3 = rt.slice(rt.search("a002a")+5,rt.search("a003a")).split(',');//门店 varAllDb3
var varAllDb4 = rt.slice(rt.search("a003a")+5,rt.search("a004a")).split(',');//表头
var varAllDb5 = rt.slice(rt.search("a004a")+5,rt.search("a005a")).split(',');//派车信息 varAllDb4
var varAllDb6 = rt.slice(rt.search("a005a")+5,rt.length).split(',');//派车日期  出车日期
//汇总信息
var riqijs=0;//管理派车日期 出车日期。
var sj="";
var cp="";

for(var i=0;i<varAllDb4.length;i=i+6)
{
	var hbmd="";//合并门店
	var hbbz="";//合并备注
	
	for(var ig=0;ig<varAllDb5.length;ig=ig+5)
		{
		
		   if(varAllDb4[i].slice(0,2)==varAllDb5[ig].slice(0,2))
			   {
			   //console.log(varAllDb4[i].slice(0,2));
			   //console.log(varAllDb5[ig].slice(0,2));
			  
			   hbmd=hbmd+varAllDb5[ig].slice(2,varAllDb5[ig].length)+"/";//保存单表配送门店
			   hbbz=hbbz+varAllDb5[ig+4].slice(2,varAllDb5[ig+4].length)+"/";//保存单表备注
			   sj=varAllDb5[ig+1].slice(2,varAllDb5[ig+1].length);//保存司机
			   cp=varAllDb5[ig+2].slice(2,varAllDb5[ig+2].length);//保存车牌 
		   
			   //当前td行的司机车牌与下一td行的司机车牌不一致就写入当前td行，否则新启一行。
			   //js不能处理数组跨界异常，只能手动处理，到最后一行td直接处理数据。php可以处理跨界异常直接返回false，js直接退出。
			   if(ig!=varAllDb5.length-5){
			   if(sj!=varAllDb5[ig+5+1].slice(2,varAllDb5[ig+5+1].length)&&cp!=varAllDb5[ig+5+2].slice(2,varAllDb5[ig+5+2].length))
			   {
				   //正常合并在写入前判定是否跨表，如果不跨表则正常写入。
				   if(varAllDb4[i].slice(0,2)==varAllDb5[ig+5].slice(0,2))
	                 {
				        //alert("1");
				        hbmd=hbmd.slice(0,hbmd.length-1);
				        hbbz=hbbz.slice(0,hbbz.length-1);
			            $('#wwf').children("table").children("tbody").append("<tr>"             
					    +"<th>"+varAllDb6[riqijs].slice(2,varAllDb6[riqijs].length)+"</th>"
					    +"<th>"+varAllDb6[riqijs+1].slice(2,varAllDb6[riqijs+1].length)+"</th>"
					    +"<th>"+varAllDb4[i].slice(2,varAllDb4[i].length)+"</th>"
					    +"<th>"+varAllDb4[i+1].slice(2,varAllDb4[i+1].length)+"</th>"
					    +"<th>"+varAllDb4[i+2].slice(2,varAllDb4[i+2].length)+"</th>"
					    +"<th>"+varAllDb4[i+3].slice(2,varAllDb4[i+3].length)+"</th>"
					    +"<th>"+varAllDb4[i+4].slice(2,varAllDb4[i+4].length)+"</th>"
					    +"<th>"+varAllDb4[i+5].slice(2,varAllDb4[i+5].length)+"</th>"
					    +"<th>"+hbmd+"</th>"
					    +"<th>"+varAllDb5[ig+1].slice(2,varAllDb5[ig+1].length)+"</th>"
					    +"<th>"+varAllDb5[ig+2].slice(2,varAllDb5[ig+2].length)+"</th>"
					    +"<th>"+varAllDb5[ig+3].slice(2,varAllDb5[ig+3].length)+"</th>"	
					    +"<th>"+hbbz+"</th>"
					    +"</tr>");
			            var hbmd="";//合并门店
			            var hbbz="";//合并门店
	                 }
			   }
			   //如果跨表 则直接写入数据。
			   if(varAllDb4[i].slice(0,2)!=varAllDb5[ig+5].slice(0,2))
               {
				    //alert("2");
				    hbmd=hbmd.slice(0,hbmd.length-1);
				    hbbz=hbbz.slice(0,hbbz.length-1);
		            $('#wwf').children("table").children("tbody").append("<tr>"             
				    +"<th>"+varAllDb6[riqijs].slice(2,varAllDb6[riqijs].length)+"</th>"
				    +"<th>"+varAllDb6[riqijs+1].slice(2,varAllDb6[riqijs+1].length)+"</th>"
				    +"<th>"+varAllDb4[i].slice(2,varAllDb4[i].length)+"</th>"
				    +"<th>"+varAllDb4[i+1].slice(2,varAllDb4[i+1].length)+"</th>"
				    +"<th>"+varAllDb4[i+2].slice(2,varAllDb4[i+2].length)+"</th>"
				    +"<th>"+varAllDb4[i+3].slice(2,varAllDb4[i+3].length)+"</th>"
				    +"<th>"+varAllDb4[i+4].slice(2,varAllDb4[i+4].length)+"</th>"
				    +"<th>"+varAllDb4[i+5].slice(2,varAllDb4[i+5].length)+"</th>"
				    +"<th>"+hbmd+"</th>"
				    +"<th>"+varAllDb5[ig+1].slice(2,varAllDb5[ig+1].length)+"</th>"
				    +"<th>"+varAllDb5[ig+2].slice(2,varAllDb5[ig+2].length)+"</th>"
				    +"<th>"+varAllDb5[ig+3].slice(2,varAllDb5[ig+3].length)+"</th>"	
				    +"<th>"+hbbz+"</th>"
				    +"</tr>");
		            var hbmd="";//合并门店
		            var hbbz="";//合并门店
				   
			   }
			   }else{
				            hbmd=hbmd.slice(0,hbmd.length-1);
				            hbbz=hbbz.slice(0,hbbz.length-1);
				            $('#wwf').children("table").children("tbody").append("<tr>"             
						    +"<th>"+varAllDb6[riqijs].slice(2,varAllDb6[riqijs].length)+"</th>"
						    +"<th>"+varAllDb6[riqijs+1].slice(2,varAllDb6[riqijs+1].length)+"</th>"
						    +"<th>"+varAllDb4[i].slice(2,varAllDb4[i].length)+"</th>"
						    +"<th>"+varAllDb4[i+1].slice(2,varAllDb4[i+1].length)+"</th>"
						    +"<th>"+varAllDb4[i+2].slice(2,varAllDb4[i+2].length)+"</th>"
						    +"<th>"+varAllDb4[i+3].slice(2,varAllDb4[i+3].length)+"</th>"
						    +"<th>"+varAllDb4[i+4].slice(2,varAllDb4[i+4].length)+"</th>"
						    +"<th>"+varAllDb4[i+5].slice(2,varAllDb4[i+5].length)+"</th>"
						    +"<th>"+hbmd+"</th>"
						    +"<th>"+varAllDb5[ig+1].slice(2,varAllDb5[ig+1].length)+"</th>"
						    +"<th>"+varAllDb5[ig+2].slice(2,varAllDb5[ig+2].length)+"</th>"
						    +"<th>"+varAllDb5[ig+3].slice(2,varAllDb5[ig+3].length)+"</th>"	
						    +"<th>"+hbbz+"</th>"
						    +"</tr>");
				            var hbmd="";//合并门店
				            var hbbz="";//合并门店
			   }			  
			   } 
		   				  
		}
	
	
	riqijs=riqijs+2;
} 
var a01=varAllDb1;//车牌 varAllDb1
var a02=varAllDb2;//司机 varAllDb2
var a03=varAllDb3;//门店 varAllDb3
var a04=varAllDb5;//派车信息 varAllDb4
//如果司机 车牌 门店 在派车信息中被找到则删除相应元素。 商超按全体车牌 司机 配送比对，未使用的直接标注（连锁，王伟峰）式样.
for(var i=0;i<varAllDb1.length;i=i+1)
{
	for(var ig=0;ig<varAllDb5.length;ig=ig+1){
		if(varAllDb1[i]==varAllDb5[ig].slice(2,varAllDb5[ig].length))
		{		
			delete a01[i-1];//找到使用车牌后删除车牌和它的前置备注。	
			delete a01[i];			
		}
	}	
}
for(var i=0;i<varAllDb2.length;i=i+1)
{
	for(var ig=0;ig<varAllDb5.length;ig=ig+1){
		if(varAllDb2[i]==varAllDb5[ig].slice(2,varAllDb5[ig].length))
		{	
			delete a02[i-1];//找到使用司机后删除司机和它的前置备注。	
			delete a02[i];			
		}
	}	
}
for(var i=0;i<varAllDb3.length;i=i+1)
{
	for(var ig=0;ig<varAllDb5.length;ig=ig+1){
		if(varAllDb3[i]==varAllDb5[ig].slice(2,varAllDb5[ig].length))
		{			
			delete a03[i];			
		}
	}	
}
//去除空值。
var r1 = a01.filter(function (s) {
	   return s && s.trim();
	});
var r2 = a02.filter(function (s) {
	   return s && s.trim();
	});
var r3 = a03.filter(function (s) {
	   return s && s.trim();
	});
$('#a01').text("未使用车辆:"+r1);
$('#a02').text("未使用司机:"+r2);
$('#a03').text("未派车门店:"+r3);
//$('#a04').text(a04);
</script>

</body>

</html>